package com.example.myapplication;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class Fragment3 extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    private RecyclerView recyclerView;
    public List<String> list;
    private Context context;
    private  myadapter myadapter;
    private View view;


    public Fragment3() {
        // Required empty public constructor
    }

    public static Fragment3 newInstance(String param1, String param2) {
        Fragment3 fragment = new Fragment3();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view=inflater.inflate(R.layout.fragment_3,container,false);
        recyclerView=(RecyclerView)view.findViewById(R.id.recyclerview);
        initData();


        myadapter = new myadapter(list,getActivity());
        RecyclerView.LayoutManager manager=new LinearLayoutManager(getActivity(),RecyclerView.VERTICAL,false);
        recyclerView.setAdapter(myadapter);
        recyclerView.setLayoutManager(manager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        //recyclerView.addItemDecoration(new DividerItemDecoration(context,LinearLayoutManager.VERTICAL));
        return view;

    }

    private void initData() {
        list=new ArrayList<>();
        list.add("罗志祥有一条新朋友圈");
        list.add("吴亦凡有一条新朋友圈");
        list.add("李易峰有一条新朋友圈");
        list.add("蔡徐坤有一条新朋友圈");
        list.add("周杰伦有一条新朋友圈");
        list.add("薛之谦有一条新朋友圈");
        list.add("王一博有一条新朋友圈");
        list.add("邓超有一条新朋友圈");
        list.add("郑凯有一条新朋友圈");
        list.add("李晨有一条新朋友圈");
        list.add("鹿晗有一条新朋友圈");
        list.add("王力宏有一条新朋友圈");
        list.add("林志玲有一条新朋友圈");
        list.add("林志颖有一条新朋友圈");
        list.add("林正英有一条新朋友圈");
        list.add("王菲有一条新朋友圈");
        list.add("王峰有一条新朋友圈");
        list.add("李玉刚有一条新朋友圈");
        list.add("赵丽颖有一条新朋友圈");
        list.add("王杰有一条新朋友圈");
        list.add("许嵩有一条新朋友圈");

    }
}